/**
 * @file IndexBuffer.cpp
 */
#include "StdAfx.h"
#include <d3d9.h>
#include "Graphics/src/IndexBufferImpl.h"
#include "Graphics/src/ManagerImpl.h"


namespace NTEngine {
namespace Graphics {

IndexBuffer IndexBuffer::create( int n, Format fmt ) {
	IndexBuffer instance;
	instance.m_Impl = NEW Impl( g_ManagerImpl->device(), n, fmt );
	return instance;
}

int IndexBuffer::indexNumber() const {
	return m_Impl->indexNumber();
}

IndexBuffer::IndexBuffer( const Impl* )
: m_Impl( NULL ) {
}

void* IndexBuffer::lockImpl( Format fmt ) {
	ASSERT( m_Impl && "Graphics::IndexBuffer : This is empty object." );
	ASSERT( ( fmt == m_Impl->format() ) && "Graphics::IndexBuffer : format error." );
	return m_Impl->lock();
}

void IndexBuffer::unlockImpl( Format fmt, void** pp ) {
	ASSERT( *pp && "Graphics::IndexBuffer : give LOCKED pointer." );
	ASSERT( m_Impl && "Graphics::IndexBuffer : This is empty object." );
	ASSERT( ( fmt == m_Impl->format() ) && "Graphics::IndexBuffer : format error." );
	m_Impl->unlock();
	*pp = NULL;
}

#define TYPE IndexBuffer
#include "NTEngine/Base/Impl/ReferenceTypeTemplate.h"

} // namespace Graphics
} // namespace NTEngine
// EOF